import ConfigParser

def write_basic_cfg():
    config = ConfigParser.RawConfigParser()
    # When adding sections or items, add them in the reverse order of
    # how you want them to be displayed in the actual file.
    # In addition, please note that using RawConfigParser's and the raw
    # mode of ConfigParser's respective set functions, you can assign
    # non-string values to keys internally, but will receive an error
    # when attempting to write to a file or when you get it in non-raw
    # mode. SafeConfigParser does not allow such assignments to take place.
    config.add_section('Text')
    config.set('Text', 'font', '18')
    config.set('Text', 'dposx', '20')
    config.set('Text', 'dposy', '30')
    config.add_section('Nodes')
    config.set('Nodes', 'color_array', 'stability')
    config.set('Nodes', 'label_array', 'names')
    config.set('Nodes', 'size_array', 'stability')
    config.set('Nodes', 'font_size', '15')
    config.set('Nodes', 'glyph', '6')
    config.add_section('Layout')
    config.set('Layout', 'line_width', '4')
    config.set('Layout', 'point_size', '8')
    config.set('Layout', 'window_size_x', '600')
    config.set('Layout', 'window_size_y', '600')    
    # Writing our configuration file to 'example.cfg'
    with open('cfg/lattice_drawer.cfg', 'wb') as configfile:
        config.write(configfile)

def read_cfg(path):
    config = ConfigParser.ConfigParser()
    config.read(path)
    return config

if __name__ == "__main__":
    write_basic_cfg()